home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 September
/
PCWorld_2008-09_cd.bin
/
v cisle
/
sadanastroju
/
wot-20080519-fx.xpi
/
chrome
/
wot.jar
/
content
/
api
/
link.js
next >
Wrap
Text File
|
2008-02-21
|
2KB
|
106 lines
/*
api/link.js
Copyright © 2006, 2007 Against Intuition, Inc. <info@mywot.com>
*/
var wot_api_link =
{
init: function()
{
},
send: function(rule, content, cache)
{
try {
if (!wot_api_register.ready) {
return;
}
var i, j = 0, hosts = "";
var nonce = wot_crypto.nonce();
for (i in cache) {
if (cache[i] != i ||
(wot_cache.iscached(i) && (wot_cache.get(i, "pending") ||
wot_cache.get(i, "inprogress")))) {
continue;
}
if ((hosts.length + i.length + 1) > WOT_MAX_LINK_HOSTSLEN) {
break;
}
hosts += i + "/";
wot_cache.add_nonce(nonce + "-" + j++, i);
if (j >= WOT_MAX_LINK_PARAMS) {
break;
}
}
if (hosts.length == 0) {
return;
}
var context =
wot_arc4.create(wot_hash.hmac_sha1hex(wot_prefs.witness_key,
nonce));
if (!context) {
return;
}
var crypted_hosts =
wot_arc4.crypt(context, wot_hash.strtobin(hosts));
if (!crypted_hosts) {
return;
}
var query_string = WOT_SERVICE_API_LINK +
"?id=" + wot_prefs.witness_id +
"&nonce=" + nonce +
"&hosts=" + encodeURIComponent(btoa(
wot_hash.bintostr(crypted_hosts))) +
"&lang=" + wot_util.getstring("language") +
"&version=" + WOT_PLATFORM + "-" + WOT_VERSION;
var request = new XMLHttpRequest();
request.open("GET", WOT_SERVICE_NORMAL +
wot_crypto.authenticate_query(query_string));
new wot_cookie_remover(request);
request.onload = function(event)
{
try {
if (request.status == 200) {
wot_cache.add_query(
request.responseXML.getElementsByTagName(
WOT_SERVICE_XML_LINK),
request.responseXML.getElementsByTagName(
WOT_SERVICE_XML_QUERY_TARGET),
true);
}
wot_search.update(rule, content, cache, true);
for (var i = 0; i < j; ++i) {
wot_cache.remove_nonce(nonce + "-" + i);
}
} catch (e) {
dump("wot_api_link.onload: failed with " + e + "\n");
}
}
request.send(null);
} catch (e) {
dump("wot_api_link.send: failed with " + e + "\n");
}
}
};
wot_api_link.init();